<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>账号管理</title>
{{template "header.tpl" .}}
<style type="text/css">
.acct_table,.app_table{ border-collapse:collapse;border-spacing:0px;}
.acct_table th,.app_table th{background-color: #f5f5f5;padding: 6px 8px;}
.acct_table td{padding-top: 6px;}
.app_table td{padding: 6px;border-bottom: solid 1px #ddd;}
</style>
</head>
<body style="background-color: #fff;padding: 0;">
<div class="formDiv">
    <form id="hostFrm" method="post">
        <div id="hostFrmTab" class="easyui-tabs" style="min-height:350px;height:auto" data-options="plain:false,border:false"> 
            <div title="基础信息" data-options="bodyCls:'pd20'">
                <div class="inputctl"> 
                    <input type="hidden" id="hostId" name="hostId" value="{{.host.HostId}}">
                    <input name="hostName" id="hostName" class="easyui-textbox" value="{{.host.HostName}}"
                    data-options="required:true,validType:['safeChar','maxLength[50]'],label:'主机名：',width:'95%',labelWidth:'100px'">
                </div>
                <div class="inputctl"> 
                <select name="hostType" id="hostType" class="easyui-combobox" data-options="editable:false,
                label:'类型：',width:'95%',labelWidth:'100px',valueField: 'value',textField: 'text',data:hostTypes,value:{{or .host.HostType 0}}">
                </select>
                </div>
                <div class="inputctl"> 
                    <select name="projId" id="projId" class="easyui-combobox" data-options="editable:false,
                        label:'所属项目：',width:'95%',labelWidth:'100px',panelMaxHeight:200,multiple:true,value:{{or .host.ProjIds.ToJSONString "[]"}}">
                        <option value="0">无</option>
                        {{range $key, $val := .projs}} <option value="{{$key}}">{{$val}}</option>{{end}}
                    </select>
                </div>
                <div class="inputctl"> 
                <input name="publicIp" id="publicIp" class="easyui-textbox" value="{{.host.PublicIp}}"
                data-options="validateOnCreate:false,validType:'maxLength[32]',label:'公网IP：',width:'95%',labelWidth:'100px'">
                </div>
                <div class="inputctl"> 
                <input name="internalIp" id="internalIp" class="easyui-textbox" value="{{.host.InternalIp}}" 
                data-options="validateOnCreate:false,validType:'maxLength[32]',label:'内网IP：',width:'95%',labelWidth:'100px'">
                </div>
                <div class="inputctl"> 
                <input name="sshPort" id="sshPort" class="easyui-numberbox" {{if ne .host.SshPort 0 }}value="{{.host.SshPort}}"{{end}}  
                data-options="validateOnCreate:false,max:65535,width:'95%',label:'SSH端口：',labelWidth:'100px'">
                </div>
                <div class="inputctl"> 
                <select name="osName" id="osName" class="easyui-combobox" data-options="editable:false,
                label:'操作系统：',width:'95%',labelWidth:'100px',panelMaxHeight:200, value:'{{.host.OsName}}'">
                <option value="">-请选择-</option>
                {{range $val := .osnames}} <option>{{$val}}</option>{{end}}
                </select>
                </div>
                <div class="inputctl"> 
                <textarea name="desc" id="desc" class="easyui-textbox" data-options="validateOnCreate:false,validType:'maxLength[500]',
                width:'95%',label:'备注：',labelWidth:'100px',multiline:true" style="height:85px">{{.host.Desc}}</textarea>
                </div>
            </div>
            <div title="账号设置" data-options="bodyCls:'pd20'">
               <table class="acct_table" style="width:100%;">
                 <tr><th style="width:50%;">用户名</th><th style="width:50%;">密码</th></tr>
                 {{ .host.ToBuildAccountHTML | str2html }}
               </table>
            </div>
            <div title="部署应用" data-options="bodyCls:'pd20'">
                <table class="app_table" style="width:100%;">
                <tr><th style="width:40%;">应用名</th><th style="width:50%;">地址</th></tr>
                {{if .host.Apps}}
                    {{range $app := .host.Apps}}<tr><td>{{$app.AppName}}</td><td>{{$app.AppUrl}}</td></tr>{{end}}
                {{else}}
                <tr><td colspan="2" style="text-align: center;">暂未部署应用</td></tr>
                {{end}}
                </table>
            </div>
        </div>
    </form>
</div>
<script src="/static/js/hostapp.js"></script>

</body>
</html>